# Maintainer: Guillaume ALAUX <guillaume@archlinux.org>
pkgname=('java-commons-daemon' 'java-jsvc')
pkgbase=java-commons-daemon
pkgver=1.0.15
pkgrel=3
arch=('i686' 'x86_64')
url='https://commons.apache.org/proper/commons-daemon/'
license=('APACHE')
_libname=commons-daemon
source=(https://archive.apache.org/dist/commons/daemon/source/${_libname}-${pkgver}-src.tar.gz{,.asc})
validpgpkeys=('F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23') # Mladen Turk (Default signing key)
sha256sums=('11ee57d2c6b281589c1497b2f88180553f06d5ac1560ce1841e05f89f0342432'
            'SKIP')
makedepends=('apache-ant' 'docbook2x' 'docbook-xsl')

build() {
  # commons-daemon.jar
  cd "${srcdir}/${_libname}-${pkgver}-src"
  ant

  # jsvc
  cd "${srcdir}/${_libname}-${pkgver}-src/src/native/unix"
  JAVA_HOME=/usr/lib/jvm/default ./configure
  make
  docbook2man man/jsvc.1.xml
}

package_java-commons-daemon() {
  pkgdesc='Alternative invocation mechanism for unix-daemon-like java code'
  depends=('java-runtime')

  cd "${srcdir}/${_libname}-${pkgver}-src"

  install -Dm644 dist/${_libname}-${pkgver}.jar \
                 ${pkgdir}/usr/share/java/${_libname}-${pkgver}.jar
  ln -s ${_libname}-${pkgver}.jar \
        ${pkgdir}/usr/share/java/${_libname}.jar
}

package_java-jsvc() {
  pkgdesc='Apache application for making Java applications run on UNIX more easily'
  depends=("java-${_libname}" 'libcap')

  cd "${srcdir}/${_libname}-${pkgver}-src/src/native/unix"

  install -Dm755 jsvc ${pkgdir}/usr/bin/jsvc
  install -Dm644 JSVC.1 ${pkgdir}/usr/share/man/man1/JSVC.1
}

